package com.example.testjenkins.controller;

import com.example.testjenkins.service.TestService;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/")
@AllArgsConstructor
public class InfoController {

    Map<String, TestService> testMap;

    @GetMapping("/test1")
    @PreAuthorize("@rs.hasRole()")
    public String toTest() {
        return "test---jenkins---1.0";
    }

    @GetMapping("/test2")
    public String toTest1() {
        return "test---jenkins---1.1";
    }

    @GetMapping("/test/{id}")
    public String toTest3(@PathVariable String id) {
        return testMap.get("testServiceImpl" + id).callBack();
    }

}
